//
//  OptionalHeaderView.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/7/3.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "OptionalHeaderView.h"


@interface OptionalHeaderView ()


@property (nonatomic, weak)UILabel * kindLabel;

@property (nonatomic, weak)UILabel * reduceLabel;

@property (nonatomic, weak)UILabel * addLabel;



@end

@implementation OptionalHeaderView



- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        //在这里向contentView添加控件
        [self setupUI];
    }
    return self;
}


- (void)setupUI{
    
//    self.backgroundColor = [UIColor blackColor];
    
//    self.contentView.backgroundColor = [UIColor whiteColor];
//    self.contentView.alpha = 0.1;
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showOrHiddenHeaderLabel) name:@"showOrHiddenHeaderLabel" object:nil];
    
    UIView * backView = [UIView new];
    
    backView.backgroundColor = ColorWithRGB(0x061b24);
    
    [self addSubview:backView];
    
    [backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.leading.trailing.mas_equalTo(self);
    }];
    
    UILabel * kindLabel = [UILabel new];
    
    kindLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15 * SCREENH6];
    kindLabel.textColor = ColorWithRGB(0xbbbbbb);
    kindLabel.text = @"交易品种";
    
    self.kindLabel = kindLabel;
    
    [self addSubview:self.kindLabel];
    
    [self.kindLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self).offset(15 * SCREENH6);
        make.centerY.mas_equalTo(self);
    }];
    
    UILabel * reduceLabel = [UILabel new];
    
    reduceLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15 * SCREENH6];
    reduceLabel.textColor = ColorWithRGB(0xbbbbbb);
    reduceLabel.text = @"买跌价";
    
    self.reduceLabel = reduceLabel;
    
    [self addSubview:self.reduceLabel];
    
    [self.reduceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self).offset(240 * SCREENH6);
        make.centerY.mas_equalTo(self);
    }];
    
    
    UILabel * addLabel = [UILabel new];
    
    addLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:15 * SCREENH6];
    addLabel.textColor = ColorWithRGB(0xbbbbbb);
    addLabel.text = @"买涨价";
    
    self.addLabel = addLabel;
    
    [self addSubview:self.addLabel];
    
    [self.addLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self).offset(310 * SCREENH6);
        make.centerY.mas_equalTo(self);
    }];
}



- (void)showOrHiddenHeaderLabel{
    
    if (self.addLabel.hidden) {
        
        self.addLabel.hidden = NO;
        self.reduceLabel.hidden = NO;
    }else{
        
        self.addLabel.hidden = YES;
        self.reduceLabel.hidden = YES;
    }
}


//- (void)layoutSubviews
//{
//#warning 一定要记得写 不然添加的button不能处理点击事件
//    [super layoutSubviews];
//    
//}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
